﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MvcMall.Core.Contacts.Services;
using MvcMall.Core.Contacts.Tasks;
using MvcMall.Core.Enums;

namespace MvcMall.AdminWeb.Manage.StoreApplies
{
    public partial class StoreDetails : ManageBasePage
    {

        private IStoreTask _storeTask;
        protected void Page_Load(object sender, EventArgs e)
        {
            ValidatePagePower("StoreList");
            _storeTask = GetInstance<IStoreTask>();
            if (!IsPostBack)
            {
                int id = -1;
                int.TryParse(Request["ID"], out id);
                if (id > 0)
                {
                    var model = _storeTask.Get(id);
                    if (model == null)
                    {
                        ShowMsgAndReturn("末读取到该数据");
                        return;
                    }

                    ltlId.Text = model.Id.ToString();
                    ltlUser.Text = model.User.UserName;
                    ltlStoreGrade.Text = model.StoreGrade.GradeName;
                    ltlOwnerName.Text = model.OwnerName;
                    ltlStoreName.Text = model.StoreName;
                    ltlStoreCat.Text = model.StoreCat.CatName;
                    ltlStoreType.Text = model.StoreType.Equals(MvcMall.Core.Enums.StoreType.个人兼职) ? "个人兼职" : model.Equals(MvcMall.Core.Enums.StoreType.个人全职) ? "个人全职" : model.Equals(MvcMall.Core.Enums.StoreType.公司开店) ? "公司开店" : model.Equals(MvcMall.Core.Enums.StoreType.有实体店铺) ? "有实体店铺" : "错误类型";
                    ltlStoreIntro.Text = model.StoreIntro;
                    ltlStoreDesc.Text = model.StoreDesc;
                    ltlPromoteUser.Text = model.PromoteUser != null ? model.PromoteUser.UserName : "";
                    ltlStoreStatus.Text = model.StoreStatus.Equals(StoreStatus.正常) ? "正常" : "锁定";
                    ltlIdentityCardId.Text = model.IdentityCardId;
                    string imgUrl = model.IdentityCardImage;
                    ltlStateImg.Text = string.Format("<img style=\" width:500px; height:350px;\"  src=\"{0}\" />", imgUrl);
                    string yingImgUrl = model.LicenseImage;
                    ltlYingImg.Text = string.Format("<img style=\" width:500px; height:350px;\"  src=\"{0}\" />", yingImgUrl);
                    ltlCreateDate.Text = model.CreateTime.ToString();
                    ltlUrlId.Text = string.Format("<a href='Address.aspx?ID={0}' >配送方式</a>", model.Id);

                }
                else
                {
                    ShowMsgAndReturn("末读取到该数据");
                    return;
                }
            }
        }
    }
}